<template>
  <!-- 试题管理 -->
  <div class="app-container">
    <!-- 查询 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="科目:" prop="subjectId">
        <el-select
          v-model="queryParams.subjectId"
          placeholder="请选择科目"
          clearable
          size="small"
          @change="infochange"
        >
          <el-option
            v-for="dict in kelist"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="章:" prop="zhang">
        <el-select
          v-model="queryParams.zhang"
          placeholder="请选择章"
          clearable
          size="small"
          @change="zchange"
        >
          <el-option
            v-for="dict in zlist"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="节:" prop="jie">
        <el-select
          v-model="queryParams.jie"
          placeholder="请选择节"
          clearable
          size="small"
          @change="jchange"
        >
          <el-option
            v-for="dict in jlist"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="知识点:" prop="knowledgeId">
        <el-select
          v-model="queryParams.knowledgeId"
          placeholder="请选择知识点"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in outlineList"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="题型:" prop="questionTypeId">
        <el-select
          v-model="queryParams.questionTypeId"
          placeholder="请选择题型"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in typelist"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="题干:" prop="questionsContent">
        <el-input
          v-model="queryParams.questionsContent"
          placeholder="请输入题干"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <!-- <el-form-item label="命题人:" prop="expertName">
            <el-input
            v-model="queryParams.expertName"
            placeholder="请输入命题人"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
            />
        </el-form-item> -->
      <el-form-item label="录入时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
        ></el-date-picker>
      </el-form-item>

      <el-form-item label="使用状态:" prop="useStatus">
        <el-select
          v-model="queryParams.useStatus"
          placeholder="请选择使用状态"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in chastatuslist"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        label="审核状态:"
        prop="verityStatus"
        v-hasPermi="['system:questions:verity']"
      >
        <el-select
          v-model="queryParams.verityStatus"
          placeholder="请选择审核状态"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in verityStatuslist"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="试题编号:" prop="id">
        <el-input
          v-model="queryParams.id"
          placeholder="请输入试题编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <!-- 新增修改 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:questions:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['system:user:import']"
          >导入</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['system:user:import']"
          >excel导入</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="batchaudit"
          v-hasPermi="['system:questions:add']"
        >批量审核</el-button>
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <!-- 试题表 -->
    <el-table
      v-loading="loading"
      :data="infoList"
      :row-class-name="tableRowClassName"
    >
      <el-table-column
        label="序号"
        type="index"
        width="70"
        :index="indexMetthod"
        align="center"
      >
      </el-table-column>
      <el-table-column label="试题编号" align="center" prop="id" width="80" />
      <el-table-column
        label="题型"
        align="center"
        prop="questionType"
        width="80"
      />
      <el-table-column label="题干" align="center" prop="questionsContent" />
        <!-- <template slot-scope="scope">
              <span v-html="scope.row.questionsContent"></span>
            </template>
      </el-table-column>    -->
      <el-table-column label="科目" align="center" prop="subject" width="80" />
      <el-table-column
        label="知识点"
        align="center"
        prop="knowledge"
        width="150"
      />
      <el-table-column
        label="审核状态"
        align="center"
        prop="verityStatus"
        width="80"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.verityStatus == 0">待审核</span>
          <span v-else-if="scope.row.verityStatus == 1">初审通过</span>
          <span v-else-if="scope.row.verityStatus == 2">审核完毕</span>
          <span v-else>暂无状态</span>
        </template>
      </el-table-column>
      <el-table-column
        label="命题人"
        align="center"
        prop="expertName"
        width="80"
      />
      <el-table-column
        label="录入人"
        align="center"
        prop="createOperator"
        width="80"
      />
      <el-table-column
        label="录入时间"
        align="center"
        prop="createTime"
        width="150"
      />
      <el-table-column
        label="使用状态"
        align="center"
        prop="useStatus"
        width="80"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.useStatus == 0">激活期</span>
          <span v-else-if="scope.row.useStatus == 1">封存期</span>
          <span v-else-if="scope.row.useStatus == 2">待删除</span>
          <span v-else>暂无状态</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="300"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:questions:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="lookhistory(scope.row)"
            v-hasPermi="['system:history:list']"
            >历史</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:questions:remove']"
            >删除</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit-outline"
            @click="threeUpdate(scope.row)"
            v-hasPermi="['system:questions:edit']"
            >修改使用状态</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-success"
            @click="audit(scope.row)"
            v-hasPermi="['system:questions:verity']"
          >
            <span v-if="scope.row.verityStatus == 0">审核</span>
            <span v-else-if="scope.row.verityStatus == 1">复审</span>
            <span v-else-if="scope.row.verityStatus == 2">查看</span>
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页器 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改试题信息对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1000px"
      append-to-body
      @close="cancel"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <!-- 科目  题型 -->
        <el-row>
          <el-col :span="12">
            <el-form-item label="科目" prop="subjectId">
              <el-select
                v-model="form.subjectId"
                placeholder="请选择"
                ref="gain"
                @change="kmtwo"
                v-if="geiyas == false"
              >
                <el-option
                  v-for="item in kelist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
              <el-select
                v-model="form.subjectId"
                placeholder="请选择"
                ref="gain"
                @change="kmtwo"
                v-else
                :disabled="true"
              >
                <el-option
                  v-for="item in kelist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="题型" prop="questionTypeId">
              <el-select
                v-model="form.questionTypeId"
                placeholder="请选择"
                @change="questionTypechange"
                v-if="form.zhang != 45 && geiyas == false"
              >
                <el-option
                  v-for="item in typelist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
              <el-select
                v-model="form.questionTypeId"
                placeholder="请选择"
                @change="questionTypechange"
                v-else
                :disabled="true"
              >
                <el-option
                  v-for="item in typelist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 章 命题人-->
        <el-row>
          <el-col :span="12">
            <el-form-item label="章" prop="zhang">
              <!-- <el-select v-model="form.zhang" placeholder="请选择" @change="zchange" v-if="geiyas == false"> -->
              <el-select
                v-model="form.zhang"
                placeholder="请选择"
                @change="zchange"
              >
                <el-option
                  v-for="item in zlist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
              <!-- <el-select v-model="form.zhang" placeholder="请选择"  :disabled="true">
                <el-option
                v-for="item in zlist"
                :key="item.id"
                :label="item.name"
                :value="item.id"
                />
            </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="命题人" prop="expertName">
              <el-select v-model="form.expertName" placeholder="请选择">
                <el-option
                  v-for="item in personlist"
                  :key="item.userId"
                  :label="item.userName"
                  :value="item.userId"
                />
              </el-select>
            </el-form-item>
            <!-- <el-input  v-model.trim="form.expertName" placeholder="请输入" maxlength="10" style="width:218px;"  />
            </el-form-item> -->
          </el-col>
        </el-row>
        <!-- 节  错误率-->
        <el-row>
          <el-col :span="12">
            <el-form-item label="节" prop="jie">
              <!-- <el-select v-model="form.jie" placeholder="请选择" @change="jchange"  v-if="geiyas == false"> -->
              <el-select
                v-model="form.jie"
                placeholder="请选择"
                @change="jchange"
              >
                <el-option
                  v-for="item in jlist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
              <!-- <el-select v-model="form.jie" placeholder="请选择" v-else :disabled="true">
                <el-option
                v-for="item in jlist"
                :key="item.id"
                :label="item.name"
                :value="item.id"
                />
            </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="错误率" prop="difficulty">
              <el-select
                v-if="form.zhang != 45"
                v-model="form.difficulty"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in difficultylist"
                  :key="item.id"
                  :label="item.difficultyName"
                  :value="item.id"
                />
              </el-select>
              <el-select v-else v-model="form.difficulty" :disabled="true">
                <el-option
                  v-for="item in difficultylist"
                  :key="item.id"
                  :label="item.difficultyName"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 知识点  知识点重要度 -->
        <el-row>
          <el-col :span="12">
            <el-form-item label="知识点" prop="knowledgeId">
              <!-- <el-select v-model="form.knowledgeId" placeholder="请先选择" @change="impidchange"  v-if="geiyas == false" > -->
              <el-select
                v-model="form.knowledgeId"
                placeholder="请先选择"
                @change="impidchange"
              >
                <el-option
                  v-for="item in outlineList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
              <!-- <el-select v-model="form.knowledgeId" placeholder="请先选择" @change="impidchange" :disabled="true" v-else>
                <el-option 
                v-for="item in outlineList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
                />
            </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="知识点重要度" prop="importanceId">
              <el-select v-model="form.importanceId" :disabled="true">
                <el-option
                  v-for="item in outlineList"
                  :key="item.id"
                  :label="item.importance"
                  :value="item.importanceId"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- 时效   有效期限 -->
        <el-row>
          <el-col :span="12">
            <el-form-item label="试题时效" prop="aging">
              <el-select v-model="form.aging" placeholder="请选择">
                <el-option
                  v-for="item in aginglist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12" v-if="form.aging == 0">
            <el-form-item label="有效期限" prop="validTime">
              <el-date-picker
                clearable
                size="small"
                v-if="this.form.aging !== 1"
                v-model="form.validTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择有效期限"
              >
              </el-date-picker>

              <el-input
                v-else
                v-model.trim="form.code"
                placeholder="请输入"
                maxlength="10"
                style="width: 218px"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <!--   地市二级联动-->
        <el-row>
          <el-col :span="7">
            <el-form-item label="所属地市" prop="shi">
              <el-select
                v-model="form.shi"
                placeholder="请选择省份"
                style="width: 150px"
                @change="changearea"
              >
                <el-option
                  v-for="item in arealist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-select
              v-model="form.belongArea"
              placeholder="请选择市区"
              style="width: 120px"
              @change="changequ"
            >
              <el-option
                v-for="item in qulist"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-col>
        </el-row>
        <!-- 特定背景 -->
        <el-row>
          <el-col>
            <el-form-item label="特定背景" prop="specificBackground">
              <el-input
                type="textarea"
                maxlength="400"
                v-model.trim="form.specificBackground"
                placeholder="请输入"
                :autosize="{ minRows: 5, maxRows: 5 }"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 题干 -->
        <el-row>
          <el-form-item
            label="材料背景"
            prop="questionsContent"
            v-if="form.questionTypeId == 5"
          >
            <span class="iconclick" @click="addcropper">图片裁剪</span>

            <span
              class="iconclicks"
              @click="addcha"
              v-if="
                form.questionTypeId &&
                form.questionsContent !== null &&
                form.questionsContent !== '<p><br></p>' &&
                !this.geiyas
              "
              >查重</span
            >
            <span class="iconclicks" @click="addchas" v-else-if="!this.geiyas"
              >查重</span
            >
            <span v-else></span>

            <Editor
              v-model="form.questionsContent"
              style="height: 150px; margin-bottom: 50px"
            ></Editor>
          </el-form-item>
          <el-form-item label="试题题干" prop="questionsContent" v-else>
            <span class="iconclick" @click="addcropper">图片裁剪</span>

            <span
              class="iconclicks"
              @click="addcha"
              v-if="
                form.questionTypeId &&
                form.questionsContent !== null &&
                form.questionsContent !== '<p><br></p>' &&
                !this.geiyas
              "
              >查重</span
            >
            <span class="iconclicks" @click="addchas" v-else-if="!this.geiyas"
              >查重</span
            >
            <span v-else></span>

            <Editor
              v-model="form.questionsContent"
              style="height: 150px; margin-bottom: 50px"
            ></Editor>
          </el-form-item>
        </el-row>
        <!-- 单选多选 -->
        <el-form-item
          label="选项信息"
          v-if="form.questionTypeId == 1 || form.questionTypeId == 2"
        >
          <div style="margin-bottom: 40px">&nbsp;</div>
          <div
            style="display: flex; align-items: flex-start; margin-bottom: 50px"
            v-for="(item, index) in form.rtOptionsInfos"
            :key="index"
          >
            <div class="xuanze">
              <input
                type="checkbox"
                v-model="item.instatus"
                @change="xuanchange(index)"
              />
              <span>{{ item.option }}</span>
            </div>
            <el-form-item
              :prop="`rtOptionsInfos[${index}].remark`"
              :rules="{
                required: true,
                message: '请输入选项答案',
                trigger: 'blur',
              }"
            >
              <span class="iconclick" @click="danclick(index)">图片裁剪</span>
              <Editor
                :class="{ red: item.isAnswer != 0 }"
                v-model="item.remark"
                style="margin-bottom: 50px; height: 150px; width: 700px"
              >
              </Editor>
            </el-form-item>
          </div>
          <div class="jian">
            <span @click="jianclick">-</span>
          </div>
          <div class="jia" @click="jiaclick">+添加选项</div>
        </el-form-item>
        <!-- </el-row> -->
        <!-- 填空题  isCorrect -->
        <el-form-item
          label="选项信息"
          prop="questionsContent"
          v-if="form.questionTypeId == 3"
        >
        </el-form-item>
        <!-- 判断题  isCorrect -->
        <el-form-item
          label="选项信息 "
          prop="questionsContent"
          v-if="form.questionTypeId == 4"
        >
          <div>(选中的为正确答案)</div>
          <div
            style="
              display: flex;
              justify-content: flex-start;
              margin-bottom: 20px;
            "
            v-for="(item, index) in form.rtOptionsInfos"
            :key="index"
          >
            <el-form-item
              :prop="`rtOptionsInfos[${index}].instatus`"
              :rules="{
                required: true,
                message: '请输入选项答案',
                trigger: 'blur',
              }"
            >
              <div class="noyes">
                <input
                  type="checkbox"
                  v-model="item.instatus"
                  @change="xuanchange(index)"
                />
                <span>{{ item.text }}</span>
              </div>
            </el-form-item>
          </div>
        </el-form-item>
        <!-- 案例题 -->
        <el-form-item
          style="width: 860px; margin-left: 100px"
          label-width="0"
          v-if="form.questionTypeId == 5"
        >
          <div
            class="casestyle"
            v-for="(item, index) in form.rtQuestionsInfos"
            :key="index"
          >
            <el-form :model="form.rtQuestionsInfos[index]" label-width="120px">
              <div class="canceldiv">
                <div>
                  <span @click="cancelCase(index)">{{
                    form.rtQuestionsInfos[index].close
                  }}</span>
                </div>
                <p>小题（{{ index + 1 }}）</p>
              </div>
              <el-col style="display: flex">
                <el-form-item label="题型" label-width="70px">
                  <el-select
                    v-model="form.rtQuestionsInfos[index].questionTypeId"
                    placeholder="请选择"
                    @change="antixingchange(index)"
                  >
                    <el-option
                      v-for="item in caseTypelist"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>

                <el-form-item
                  v-if="form.zhang == 45"
                  label="错误率"
                  label-width="70px"
                >
                  <el-select
                    v-model="form.rtQuestionsInfos[index].difficulty"
                    placeholder="请选择"
                    @change="ancwlchange(form.rtQuestionsInfos)"
                  >
                    <el-option
                      v-for="item in difficultylist"
                      :key="item.id"
                      :label="item.difficultyName"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <div v-if="form.rtQuestionsInfos[index].questionTypeId == 1">
                <el-form-item
                  label="试题题干"
                  label-width="80px"
                  style="margin: 20px 0 50px 0"
                  v-if="form.rtQuestionsInfos[index].questionTypeId == 1"
                >
                  <span class="iconclick" @click="anliclick(index)"
                    >图片裁剪</span
                  >
                  <Editor
                    v-model="form.rtQuestionsInfos[index].questionsContent"
                    style="height: 150px; margin-bottom: 60px"
                  ></Editor>
                </el-form-item>
                <div
                  style="
                    display: flex;
                    align-items: flex-start;
                    margin-bottom: 50px;
                  "
                  v-for="(items, key) in form.rtQuestionsInfos[index]
                    .rtOptionsInfos"
                  :key="key"
                >
                  <div class="xuanze">
                    <input
                      type="checkbox"
                      @change="casechange(key, index)"
                      v-model="items.instatus"
                    />
                    <span>{{ items.option }}</span>
                  </div>
                  <div>
                    <span class="iconclick" @click="anlidanclick(key, index)"
                      >图片裁剪</span
                    >
                    <Editor
                      :class="{ red: items.isAnswer != 0 }"
                      v-model="items.remark"
                      style="height: 150px; width: 600px"
                    ></Editor>
                  </div>
                </div>
                <div class="casesjian">
                  <span
                    v-if="
                      form.rtQuestionsInfos[index].rtOptionsInfos.length > 1
                    "
                    @click="casecjianclick(index)"
                    >-</span
                  >
                </div>
                <div class="jia" @click="caseclick(index)">+添加选项</div>
              </div>

              <el-form-item
                label="试题题干"
                label-width="70px"
                style="margin: 20px 0 50px 0"
                v-if="form.rtQuestionsInfos[index].questionTypeId == 6"
              >
                <span class="iconclick" @click="anliclick(index)"
                  >图片裁剪</span
                >

                <Editor
                  v-model="form.rtQuestionsInfos[index].questionsContent"
                  style="height: 150px; margin-bottom: 60px"
                ></Editor>
                <el-form-item label="问答答案" label-width="70px">
                  <span class="iconclick" @click="anlijianclick(index)"
                    >图片裁剪</span
                  >
                  <Editor
                    v-model="form.rtQuestionsInfos[index].answer"
                    style="height: 150px; width: 600px"
                  ></Editor>
                </el-form-item>
              </el-form-item>
            </el-form>
          </div>
        </el-form-item>
        <div class="jia" @click="caseclickxiao" v-if="form.questionTypeId == 5">
          +添加小题
        </div>

        <!-- 问答题 -->
        <el-row v-if="form.questionTypeId == 6">
          <el-form-item label="问答答案" prop="answer">
            <span class="iconclick" @click="wenclick">图片裁剪</span>
            <Editor
              v-model="form.answer"
              style="height: 150px; width: 650px; margin-bottom: 50px"
            ></Editor>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 历史弹出框 -->
    <el-dialog
      :title="towtitle"
      :visible.sync="towopen"
      width="1500px"
      append-to-body
    >
      <el-table
        v-loading="loading"
        :data="history"
        :row-class-name="tableRowClassName"
      >
        <el-table-column
          label="序号"
          type="index"
          width="70"
          :index="towindexMetthod"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="操作类型"
          align="center"
          prop="operType"
          width="120"
        />

        <el-table-column
          label="变更前内容"
          align="center"
          prop="questionBefore"
          class="questiontext"
        >
          <template slot-scope="scope">
            <!-- <span style="max-height:100px;" > {{scope.row.questionBefore}} </span> -->
            <span style="max-height: 100px" :title="scope.row.questionBefore">
              {{ scope.row.questionBefore }}
            </span>
          </template>
        </el-table-column>

        <el-table-column label="变更后内容" align="center" prop="questionAfter">
          <template slot-scope="scope">
            <span style="max-height: 100px" :title="scope.row.questionAfter">
              {{ scope.row.questionAfter }}
            </span>
          </template>
        </el-table-column>

        <el-table-column
          label="操作人"
          align="center"
          prop="operName"
          width="100"
        />
        <el-table-column
          label="操作时间"
          align="center"
          prop="operTime"
          width="150"
        />
      </el-table>

      <pagination
        v-show="towtotal > 0"
        :total="towtotal"
        :page.sync="historyid.pageNum"
        :limit.sync="historyid.pageSize"
        @pagination="getlooklist"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="towcancel">关 闭</el-button>
      </div>
    </el-dialog>
    <!-- 修改使用状态 -->
    <el-dialog
      :title="threetitle"
      :visible.sync="threeopen"
      width="600px"
      append-to-body
    >
      <el-form label-width="120px" :model="theform">
        <el-form-item label="使用状态" prop="useStatus">
          <el-select
            v-model="theform.useStatus"
            placeholder="请选择"
            ref="gain"
          >
            <el-option
              v-for="item in threelist"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="解封日期"
          prop="lockEndTime"
          v-if="this.theform.useStatus == 1"
        >
          <el-date-picker
            clearable
            size="small"
            v-model="theform.lockEndTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择解封日期"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="threesubmitForm">确 定</el-button>
        <el-button @click="threecancel">关 闭</el-button>
      </div>
    </el-dialog>
    <!-- 审核 -->
    <el-dialog
      :title="audittitle"
      :visible.sync="auditopen"
      width="1200px"
      append-to-body
    >
      <el-form label-width="120px" :model="auditform">
        <!-- 第一行   科目 章 节 知识点 -->
        <el-row>
          <el-col :span="6">
            <el-form-item label="科目" prop="subjectId">
              <el-select
                v-model="auditform.subjectId"
                placeholder="无"
                ref="gain"
                @change="kmtwo"
                :disabled="true"
              >
                <el-option
                  v-for="item in kelist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="章" prop="zhang">
              <el-select
                v-model="auditform.zhang"
                placeholder="无"
                :disabled="true"
              >
                <el-option
                  v-for="item in zlist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="节" prop="jie">
              <el-select
                v-model="auditform.jie"
                placeholder="无"
                :disabled="true"
              >
                <el-option
                  v-for="item in jlist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="知识点" prop="knowledgeId">
              <el-select
                v-model="auditform.knowledgeId"
                placeholder="无"
                :disabled="true"
              >
                <el-option
                  v-for="item in outlineList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第二行   错误率  知识点重要度   地市 -->
        <el-row>
          <el-col :span="6">
            <el-form-item label="错误率" prop="difficulty">
              <el-select
                v-model="auditform.difficulty"
                placeholder="无"
                :disabled="true"
              >
                <el-option
                  v-for="item in difficultylist"
                  :key="item.id"
                  :label="item.difficultyName"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="知识点重要度" prop="importanceId">
              <el-select v-model="auditform.importanceId" :disabled="true">
                <el-option
                  v-for="item in outlineList"
                  :key="item.id"
                  :label="item.importance"
                  :value="item.importanceId"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="7">
            <el-form-item label="所属地市" prop="shi">
              <el-select
                v-model="auditform.shi"
                placeholder="无"
                style="width: 190px"
                :disabled="true"
              >
                <el-option
                  v-for="item in arealist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="5">
            <el-select
              v-model="auditform.belongArea"
              placeholder="无"
              style="width: 160px"
              :disabled="true"
            >
              <el-option
                v-for="item in qulist"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-col>
        </el-row>
        <!-- 第三行   题型    命题人   试题时效 -->
        <el-row>
          <el-col :span="5">
            <el-form-item label="题型" prop="questionTypeId">
              <el-select
                v-model="auditform.questionTypeId"
                placeholder="请选择"
                :disabled="true"
              >
                <el-option
                  v-for="item in typelist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="5">
            <el-form-item label="命题人" prop="expertName">
              <el-select
                v-model="auditform.expertName"
                placeholder="请选择"
                :disabled="true"
              >
                <el-option
                  v-for="item in personlist"
                  :key="item.userId"
                  :label="item.userName"
                  :value="item.userId"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="5">
            <el-form-item label="试题时效" prop="aging">
              <el-select
                v-model="auditform.aging"
                placeholder="无"
                :disabled="true"
              >
                <el-option
                  v-for="item in aginglist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="5" v-if="auditform.aging == 0">
            <el-form-item label="有效期限" prop="validTime">
              <el-date-picker
                clearable
                size="small"
                v-if="auditform.aging !== 1"
                v-model="auditform.validTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="无"
              >
              </el-date-picker>

              <el-input
                v-else
                v-model.trim="form.code"
                placeholder="请输入"
                maxlength="10"
                style="width: 218px"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- 题干  材料背景 -->
          <el-col>
            <el-form-item
              label="材料背景:"
              v-if="auditform.questionTypeId == 5"
            >
              <div
                class="imgwidth"
                v-if="auditform.subject"
                v-html="auditform.questionsContent"
              ></div>
            </el-form-item>

            <el-form-item label="题干:" v-else>
              <div
                class="imgwidth"
                v-if="auditform.subject"
                v-html="auditform.questionsContent"
              ></div>
            </el-form-item>
          </el-col>
          <!-- 单选多选题 -->
          <el-col
            v-if="
              auditform.questionTypeId == 1 || auditform.questionTypeId == 2
            "
          >
            <el-form-item label="选项信息:">
              <ul
                v-for="(item, index) in auditform.rtOptionsInfos"
                :key="index"
                style="display: flex; font-size: 20px"
              >
                <li>
                  <input
                    type="checkbox"
                    v-model="item.instatus"
                    onclick="return false;"
                    checked="checked"
                  />
                  <span v-html="item.option"></span>
                </li>
                <li
                  class="imgwidth"
                  v-html="item.remark"
                  style="margin-left: 20px"
                ></li>
              </ul>
            </el-form-item>
            <el-form-item label="试题答案:">
              <dir style="display: flex; font-size: 20px">
                <div
                  v-for="(item, index) in auditform.rtOptionsInfos"
                  :key="index"
                >
                  <span v-if="item.instatus == 1" v-html="item.option"></span>
                </div>
              </dir>
            </el-form-item>
          </el-col>
          <!-- 判断题 -->
          <el-col v-if="auditform.questionTypeId == 4">
            <el-form-item label="选项信息:">
              <ul
                v-for="(item, index) in auditform.rtOptionsInfos"
                :key="index"
                style="display: flex; font-size: 20px"
              >
                <li>
                  <input
                    type="checkbox"
                    v-model="item.instatus"
                    onclick="return false;"
                    checked="checked"
                  />
                  <span v-html="item.option"></span>
                </li>
                <li v-html="item.text" style="margin-left: 20px"></li>
              </ul>
            </el-form-item>
            <el-form-item label="试题答案:">
              <dir
                v-for="(item, index) in auditform.rtOptionsInfos"
                :key="index"
              >
                <span v-if="item.instatus == 1" v-html="item.text"></span>
              </dir>
            </el-form-item>
          </el-col>
          <!-- 案例题 -->
          <el-col v-if="auditform.questionTypeId == 5">
            <div
              v-for="(item, index) in auditform.rtQuestionsInfos"
              :key="index"
            >
              <!-- 案例题小题题干序号 -->
              <div style="text-align: center; margin-top: 20px">
                小题({{ index + 1 }})
              </div>
              <el-form-item label="试题题干:">
                <div
                  class="imgwidth"
                  v-html="auditform.rtQuestionsInfos[index].questionsContent"
                ></div>
              </el-form-item>
              <!-- 案例单选题 -->
              <div v-if="auditform.rtQuestionsInfos[index].questionTypeId == 1">
                <el-form-item label="选项信息:">
                  <ul
                    v-for="(list, key) in auditform.rtQuestionsInfos[index]
                      .rtOptionsInfos"
                    :key="key"
                    style="display: flex; font-size: 20px"
                  >
                    <li>
                      <input
                        type="checkbox"
                        v-model="list.instatus"
                        onclick="return false;"
                        checked="checked"
                      />
                      <span v-html="list.option"></span>
                    </li>
                    <li
                      class="imgwidth"
                      v-html="list.remark"
                      style="margin-left: 20px"
                    ></li>
                  </ul>
                </el-form-item>
                <el-form-item label="试题答案:">
                  <dir
                    v-for="(loop, index) in auditform.rtQuestionsInfos[index]
                      .rtOptionsInfos"
                    :key="index"
                  >
                    <span v-if="loop.instatus == 1" v-html="loop.option"></span>
                  </dir>
                </el-form-item>
              </div>
              <!-- 案例问答题 -->
              <el-form-item
                v-if="auditform.rtQuestionsInfos[index].questionTypeId == 6"
                label="问答答案:"
              >
                <div
                  class="imgwidth"
                  v-html="auditform.rtQuestionsInfos[index].answer"
                ></div>
              </el-form-item>
            </div>
          </el-col>
          <!-- 问答题 -->
          <el-col v-if="auditform.questionTypeId == 6">
            <el-form-item label="问答答案:">
              <dir>
                <span class="imgwidth" v-html="auditform.answer"></span>
              </dir>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          v-if="auditform.verityStatus != 2 && chashow == true"
          type="primary"
          @click="auditsubmitForm(auditform)"
          >审核通过</el-button
        >
        <!-- <el-button type="primary" >上一题</el-button>
        <el-button type="primary" >下一题</el-button> -->
        <el-button @click="auditcancel">关 闭</el-button>
      </div>
    </el-dialog>
    <!-- 图片剪切工具 -->
    <el-dialog
      :title="croppertitle"
      :visible.sync="cropperopen"
      width="1200px"
      append-to-body
    >
      <Cropper v-show="shownow" @imgData="imgData"></Cropper>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog
      :title="upload.title"
      :visible.sync="upload.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls, .doc"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div> -->
          <span>仅允许导入 doc 格式文件。</span>
          <el-link
            type="primary"
            :underline="false"
            style="font-size: 12px; vertical-align: baseline"
            @click="importTemplate"
            >下载模板</el-link
          >
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 查重试题对话框 -->
    <el-dialog
      :title="chatitle"
      :visible.sync="chatopen"
      width="800px"
      append-to-body
    >
      <el-table
        v-loading="loading"
        :data="chainfo"
        :row-class-name="tableRowClassName"
      >
        <el-table-column label="试题编号" align="center" prop="id" width="80" />
        <el-table-column
          label="题型"
          align="center"
          prop="questionType"
          width="80"
        />
        <!-- <el-table-column label="题干" align="center" prop="questionsContent" /> -->
        <el-form-item label="题干:">
              <div class="imgwidth" v-html="chatopen.questionsContent" ></div>
            </el-form-item>
        <el-table-column
          label="科目"
          align="center"
          prop="subject"
          width="80"
        />
        <el-table-column
          label="知识点"
          align="center"
          prop="knowledge"
          width="150"
        />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
          width="100"
        >
          <template slot-scope="scope">
            <span class="chainfoclick" @click="chainfoclick(scope.row)"
              >查看</span
            >
          </template>
        </el-table-column>
      </el-table>

      <!-- <pagination
        v-show="towtotal>0"
        :total="towtotal"
        :page.sync="chainfoid.pageNum"
        :limit.sync="chainfoid.pageSize"
        @pagination="getlooklist"
      /> -->
      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="threesubmitForm">确 定</el-button> -->
        <el-button @click="chacel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listType,
  listInfo,
  getInfo,
  delInfo,
  addInfo,
  updateInfo,
  forbidden,
  outlineinfo,
  typeinfo,
  personinfo,
  difficultyinfo,
  areainfo,
  areasinfo,
  gethistoryinfo,
  questionsInfo,
  auditInfo,
  importTemplate,
} from "@/api/system/questionsgl";
// import Editor from "@/components/Editor/index.vue"
import { getUserProfile } from "@/api/system/user";
import { getToken } from "@/utils/auth";

export default {
  name: "questionsgl",
  // components: {Editor},
  data() {
    return {
      chashow: true,
      user: {},
      // iconnum 判断剪切的图片放在哪里
      iconnum: null,
      // 存储存进来的index
      iconindex: null,
      // 存储案例的key值
      iconkey: null,
      // 判断裁剪图片工具的显示
      shownow: false,
      chastatuslist: [
        {
          id: 0,
          name: "激活期",
        },
        {
          id: 1,
          name: "封存期",
        },
        {
          id: 2,
          name: "待删除",
        },
      ],
      verityStatuslist: [
        {
          id: 0,
          name: "待审核",
        },
        {
          id: 1,
          name: "复审",
        },
        {
          id: 2,
          name: "审核通过",
        },
      ],
      dateRange: [],
      // 使用状态
      threelist: [
        {
          id: 0,
          name: "激活期",
        },
        {
          id: 1,
          name: "封存期",
        },
        {
          id: 2,
          name: "待删除",
        },
      ],
      // 历史查询id
      historyid: {
        pageNum: 1,
        pageSize: 10,
        questionId: null,
      },
      chainfoid: {
        pageNum: 1,
        pageSize: 10,
        questionId: null,
      },
      // 历史列表
      history: [],
      // 查重列表
      chainfo: [],
      // 动态添加选项
      caseTypelist: [
        {
          id: 1,
          name: "单选题",
        },
        {
          id: 6,
          name: "简答题",
        },
      ],
      // 科目下拉列表 加搜索
      kelist: [],
      // 章下拉
      zlist: [],
      // 节下拉
      jlist: [],
      //知识点下拉
      outlineList: [],
      //题型下拉
      typelist: [],
      //模块下拉
      modulelist: [],
      //难易度下拉
      difficultylist: [],
      // 命题人下拉鞋标
      personlist: [],
      //有效时效
      aginglist: [
        {
          id: 1,
          name: "无",
        },
        {
          id: 0,
          name: "有",
        },
      ],
      //地市下拉
      arealist: [],
      //区市下拉
      qulist: [],
      //单选 多选题 题列表
      singlelist: [
        {
          instatus: false,
          option: "【A】",
          isAnswer: 0,
          remark: null,
        },
      ],
      //选项A到
      test_Atrr: [
        "【A】",
        "【B】",
        "【C】",
        "【D】",
        "【E】",
        "【F】",
        "【G】",
        "【H】",
        "【I】",
        "【J】",
        "【k】",
        "【l】",
        "【m】",
        "【n】",
      ],
      // 判断题
      estimatelist: [
        {
          instatus: false,
          isAnswer: 0,
          text: "正确",
        },
        {
          instatus: false,
          isAnswer: 0,
          text: "错误",
        },
      ],
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 历史总条数
      towtotal: 0,
      // 科目信息表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 弹出层标题历史
      towtitle: "",
      // 是否显示弹出层历史
      towopen: false,
      // 弹出层标题 修改使用状态
      threetitle: "",
      // 是否显示弹出层 修改使用状态
      threeopen: false,
      // 弹出层标题 审核
      audittitle: "",
      // 是否显示弹出层 审核
      auditopen: false,
      // 弹出层标题 查重
      chatitle: "",
      // 是否显示弹出层 查重
      chatopen: false,
      croppertitle: "",
      cropperopen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        subject: null,
        knowledge: null,
        questionTypeId: null,
        questionType: null,
        questionsContent: null,
        expertName: null,
        createTime: null,
        status: null,
        knowledgeId: null,
        subjectId: null,
        zhang: null,
        jie: null,
        useStatus: null,
        verityStatus: null,
      },
      addchaquermas: {
        questionTypeId: null,
        questionsContent: null,
      },
      // 表单参数
      form: {},
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/questions/importData",
      },
      // 状态表单参数
      theform: {},
      // 审核列表
      auditform: {},
      // 表单校验
      rules: {
        subjectId: [
          { required: true, message: "科目不能为空", trigger: "change" },
        ],
        expertName: [
          { required: true, message: "命题人不能为空", trigger: "change" },
        ],
        knowledgeId: [
          { required: true, message: "知识点不能为空", trigger: "blur" },
        ],
        questionTypeId: [
          { required: true, message: "题型不能为空", trigger: "change" },
        ],
        difficulty: [
          { required: true, message: "试题难易度不能为空", trigger: "change" },
        ],
        questionsContent: [
          {
            required: true,
            message: "试题题干或者材料背景不能为空",
            trigger: "change",
          },
        ],
        remark: [
          { required: true, message: "选项不能为空", trigger: "change" },
        ],
        answer: [
          { required: true, message: "问答答案不能为空", trigger: "blur" },
        ],
      },
      // 禁用启用
      statuslist: {
        id: null,
        status: null,
      },
      // 地市
      fordishi: {
        pid: 0,
      },
      // 二级联动科目跟题型
      lianlist: {
        questionTypeId: null,
        subjectId: null,
      },
      // 修改反显传值
      xiuformlist: {
        subjectId: null,
        parentId: null,
      },
      // 科目二级联动传输数组
      xlisters: {
        subjectId: null,
        parentId: null,
      },
      // 科目二级联动传输数组
      listers: {
        subjectId: null,
        parentId: null,
      },
      // 判断修改新增
      geiyas: false,
    };
  },
  created() {
    // this.getUser()
    this.getList();
    // 科目下拉
    this.xialaList();
    //知识点下拉
    // this.outlineget();
    // 题型下拉
    this.typeget();
  },
  methods: {
    // 单选题图片裁剪
    danclick(index) {
      this.cropperopen = true;
      this.croppertitle = "图片裁剪";
      this.shownow = true;
      if (this.form.questionTypeId == 1) {
        this.iconnum = 1;
        this.iconindex = index;
      } else {
        this.iconnum = 2;
        this.iconindex = index;
      }
    },
    // 问答题裁剪
    wenclick() {
      this.cropperopen = true;
      this.croppertitle = "图片裁剪";
      this.shownow = true;

      this.iconnum = 6;
    },
    // 题干裁剪
    addcropper() {
      this.cropperopen = true;
      this.croppertitle = "图片裁剪";
      this.shownow = true;
      // 为100时是试题题干的裁剪
      this.iconnum = 100;
    },
    // 案例题裁剪
    anliclick(index) {
      this.cropperopen = true;
      this.croppertitle = "图片裁剪";
      this.shownow = true;
      this.iconnum = 5;
      this.iconindex = index;
    },
    // 案例单选
    anlidanclick(key, index) {
      this.cropperopen = true;
      this.croppertitle = "图片裁剪";
      this.shownow = true;
      this.iconkey = key;
      this.iconindex = index;
      this.iconnum = 51;
    },
    // 案例题问答 答案
    anlijianclick(index) {
      this.cropperopen = true;
      this.croppertitle = "图片裁剪";
      this.shownow = true;
      this.iconindex = index;
      this.iconnum = 56;
    },
    // 题干查询
    addcha() {
      let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g; //去除样式
      let relTag = /<.+?>/g; //去除标签
      let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g; // 清除类名
      this.form.questionsContent = this.form.questionsContent.replace(
        relStyle,
        ""
      );
      this.form.questionsContent = this.form.questionsContent.replace(
        relClass,
        ""
      );
      this.form.questionsContent = this.form.questionsContent.replace(
        relTag,
        ""
      );
      this.addchaquermas.questionsContent = this.form.questionsContent;
      this.addchaquermas.questionTypeId = this.form.questionTypeId;
      listInfo(this.addDateRange(this.addchaquermas, this.dateRange)).then(
        (response) => {
          console.log(response.rows, "row");
          if (response.rows.length < 1) {
            this.msgSuccess("试题无重复");
          } else {
            if (this.form.questionTypeId == 5) {
              // this.$confirm('材料背景重复', "提示", {
              //     confirmButtonText: "查看",
              //     cancelButtonText: "取消",
              //     type: "warning"
              //   }).then(()=> {
              //       // this.msgSuccess("材料背景重复");
              //       this.chatopen = true;
              //       this.chainfo = response.rows
              //   }).catch(() => {});
              this.chatopen = true;
              this.chainfo = response.rows;
            } else {
              // this.$confirm('试题题干重复', "提示", {
              //     confirmButtonText: "查看",
              //     cancelButtonText: "取消",
              //     type: "warning"
              //   }).then(()=> {
              // this.msgSuccess("试题题干重复");
              this.chatopen = true;
              this.chainfo = response.rows;
              // }).catch(() => {});
            }
          }
        }
      );
    },
    addchas() {
      this.$confirm("请输入题干", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {})
        .catch(() => {});
    },
    // 查重   查看按钮
    chainfoclick(row) {
      console.log(row, "row");
      console.log(row.id, "row");
      this.chashow = false;
      this.audit(row);
    },
    //子组件传的值
    imgData(val) {
      // 传过来的img的url做处理动态添加到富文本里面
      if (this.iconnum == 100) {
        // 判断为题干的时候
        if (this.form.questionsContent == null) {
          this.form.questionsContent = "";
        }
        let imgvalue = `${this.form.questionsContent}<img src=\"/dev-api${val}\">`;
        this.form.questionsContent = imgvalue;
      } else if (this.iconnum == 1 || this.iconnum == 2) {
        // 判断为单选题的时候
        if (this.form.rtOptionsInfos[this.iconindex].remark == null) {
          this.form.rtOptionsInfos[this.iconindex].remark = "";
        }
        let imgvalue = `${
          this.form.rtOptionsInfos[this.iconindex].remark
        }<img src=\"/dev-api${val}\">`;
        this.form.rtOptionsInfos[this.iconindex].remark = imgvalue;
      } else if (this.iconnum == 6) {
        // 问答题时
        if (this.form.answer == null) {
          this.form.answer = "";
        }
        let imgvalue = `${this.form.answer}<img src=\"/dev-api${val}\">`;
        this.form.answer = imgvalue;
      } else if (this.iconnum == 5) {
        // 案例题的题干
        if (
          this.form.rtQuestionsInfos[this.iconindex].questionsContent == null
        ) {
          this.form.rtQuestionsInfos[this.iconindex].questionsContent = "";
        }

        let imgvalue = `${
          this.form.rtQuestionsInfos[this.iconindex].questionsContent
        }<img src=\"/dev-api${val}\">`;
        this.form.rtQuestionsInfos[this.iconindex].questionsContent = imgvalue;
      } else if (this.iconnum == 51) {
        // 案例题单选题
        if (
          this.form.rtQuestionsInfos[this.iconindex].rtOptionsInfos[
            this.iconkey
          ].remark == null
        ) {
          this.form.rtQuestionsInfos[this.iconindex].rtOptionsInfos[
            this.iconkey
          ].remark = "";
        }
        let imgvalue = `${
          this.form.rtQuestionsInfos[this.iconindex].rtOptionsInfos[
            this.iconkey
          ].remark
        }<img src=\"/dev-api${val}\">`;
        this.form.rtQuestionsInfos[this.iconindex].rtOptionsInfos[
          this.iconkey
        ].remark = imgvalue;
      } else if (this.iconnum == 56) {
        // 案例题问答题
        if (this.form.rtQuestionsInfos[this.iconindex].answer == null) {
          this.form.rtQuestionsInfos[this.iconindex].answer = "";
        }
        let imgvalue = `${
          this.form.rtQuestionsInfos[this.iconindex].answer
        }<img src=\"/dev-api${val}\">`;
        this.form.rtQuestionsInfos[this.iconindex].answer = imgvalue;
      }

      // 关闭截图组件
      this.shownow = false;
      // 关闭截图组件 dialog 弹框
      this.cropperopen = false;
    },
    // 历史点击事件
    lookhistory(row) {
      this.towopen = true;
      this.towtitle = "历史记录";
      this.historyid.questionId = row.id;
      gethistoryinfo(this.historyid).then((response) => {
        this.history = response.rows;
        this.towtotal = response.total;
      });
    },
    // 历史  列表 （分页器）
    getlooklist() {
      gethistoryinfo(this.historyid).then((response) => {
        this.history = response.rows;
        this.towtotal = response.total;
      });
    },
    // 修改使用状态
    threeUpdate(row) {
      this.threeopen = true;
      this.threetitle = "修改使用状态";
      const id = row.id || this.ids;
      getInfo(id).then((response) => {
        this.theform = response.data;
      });
    },

    // 审核按钮
    audit(row) {
      console.log(row, "rowrowrow");
      const id = row.id || this.ids;
      getInfo(id).then((response) => {
        // 获取修改返回值
        this.auditform = response.data;
        // 获取科目id查询知识点下拉列表
        this.xiuformlist.subjectId = this.auditform.subjectId;
        // 赋值科目id传给后台
        let type = this.xiuformlist.subjectId;
        // 根据科目id查询知识点列表
        outlineinfo(this.xiuformlist, type).then((response) => {
          this.outlineList = response.rows;
          // 根据知识点查询节
          for (let i = 0; i < this.outlineList.length; i++) {
            if (this.outlineList[i].id == this.auditform.knowledgeId) {
              let jid = this.outlineList[i].parentId;
              for (let j = 0; j < this.outlineList.length; j++) {
                if (this.outlineList[j].id == jid) {
                  let zhangid = this.outlineList[j].parentId;

                  let xlisters = { ...this.xlisters };
                  xlisters.subjectId = this.auditform.subjectId;
                  xlisters.parentId = this.outlineList[j].parentId;
                  let type = this.outlineList[j].parentId;
                  outlineinfo(this.xlisters, type).then((response) => {
                    this.jlist = response.rows;
                  });
                  this.auditform.jie = Number(jid);
                  xlisters.parentId = this.outlineList[j].parentId;
                  let typeid = this.auditform.subjectId;
                  outlineinfo(this.xlisters, typeid).then((response) => {
                    this.zlist = response.rows;
                  });
                  this.auditform.zhang = Number(zhangid);
                }
              }
            }
          }
        });

        // 反显需要转Number
        this.auditform.knowledgeId = Number(this.auditform.knowledgeId);

        // 请求错误率列表反显  错误率没有联动直接请求
        this.difficultyget();

        // 请求命题人列表反显  命题人没有联动直接请求
        this.personget();
        this.auditform.expertName = Number(this.auditform.expertName);
        // 判断有没有选择地市
        if (this.auditform.belongArea != null) {
          // 反显地市 获取地市省级下拉
          areainfo(this.fordishi, 0).then((response) => {
            this.arealist = response.rows;
            this.loading = false;
          });
          // 存市的id
          let id = this.auditform.belongArea;
          // 存省的id
          let pid = null;
          //请求全部的省和市
          areasinfo()
            .then((response) => {
              let list = [];
              list = response.rows;
              // 遍历id跟返回值一样的id
              for (let i = 0; i < list.length; i++) {
                if (list[i].id == id) {
                  pid = list[i].pid;
                  this.auditform.shi = pid;
                }
              }
            })
            .then(() => {
              areainfo(this.auditform, pid).then((response) => {
                this.qulist = response.rows;
              });
            });
        } else {
          areainfo(this.fordishi, 0).then((response) => {
            this.arealist = response.rows;
            this.loading = false;
          });
        }
        console.log(this.auditform, "this.auditform");

        // 判断题型 单选题
        if (this.auditform.questionTypeId == 1) {
          let rtlist = this.auditform.rtOptionsInfos;
          for (let i = 0; i < this.auditform.rtOptionsInfos.length; i++) {
            if (rtlist[i].isAnswer == 1) {
              rtlist[i].instatus = true;
            } else if (rtlist[i].isAnswer == 0) {
              rtlist[i].instatus = false;
            } else {
            }
            rtlist[i].option = this.test_Atrr[i];
          }
        } else if (this.auditform.questionTypeId == 2) {
          //多选题
          let rtlist = this.auditform.rtOptionsInfos;
          for (let i = 0; i < this.auditform.rtOptionsInfos.length; i++) {
            if (rtlist[i].isAnswer == 1) {
              rtlist[i].instatus = true;
            } else if (rtlist[i].isAnswer == 0) {
              rtlist[i].instatus = false;
            } else {
            }
            rtlist[i].option = this.test_Atrr[i];
          }
        } else if (this.auditform.questionTypeId == 4) {
          //判断题
          if (this.auditform.isCorrect == 0) {
            let list = [
              {
                instatus: false,
                isAnswer: 0,
                text: "正确",
              },
              {
                instatus: true,
                isAnswer: 1,
                text: "错误",
              },
            ];
            this.auditform.rtOptionsInfos = list;
          } else if (this.auditform.isCorrect == 1) {
            let list = [
              {
                instatus: true,
                isAnswer: 1,
                text: "正确",
              },
              {
                instatus: false,
                isAnswer: 0,
                text: "错误",
              },
            ];
            this.auditform.rtOptionsInfos = list;
          } else {
            let list = [
              {
                instatus: false,
                isAnswer: 0,
                text: "正确",
              },
              {
                instatus: false,
                isAnswer: 0,
                text: "错误",
              },
            ];
            this.auditform.rtOptionsInfos = list;
          }
        } else if (this.auditform.questionTypeId == 5) {
          //案例题
          let rtQinfo = this.auditform.rtQuestionsInfos;
          for (let i = 0; i < rtQinfo.length; i++) {
            // 判断为单选题的时候进行遍历赋值ABCD等选项
            rtQinfo[i].close = "×";
            if (rtQinfo[i].questionTypeId == 1) {
              for (let j = 0; j < rtQinfo[i].rtOptionsInfos.length; j++) {
                rtQinfo[i].rtOptionsInfos[j].option = this.test_Atrr[j];
                if (rtQinfo[i].rtOptionsInfos[j].isAnswer == 1) {
                  rtQinfo[i].rtOptionsInfos[j].instatus = true;
                } else if (rtQinfo[i].rtOptionsInfos[j].isAnswer == 0) {
                  rtQinfo[i].rtOptionsInfos[j].instatus = false;
                } else {
                }
              }
            }
          }
        }
      });
      this.auditopen = true;
      this.audittitle = "试题审核";
      // let list = {}
      // list.id = row.id
      // list.verityStatus = 1
      // this.$confirm('确认审核数据通过？', "提示", {
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   type: "warning"
      // }).then(()=> {
      //   auditInfo(list).then(response => {

      //     this.msgSuccess("审核通过");
      //     this.getList();
      //   });
      // }).catch(() => {});
    },
    // 审核   审核通过按钮
    auditsubmitForm(row) {
      let list = {};
      list.id = row.id;
      if (this.auditform.verityStatus == 0) {
        list.verityStatus = 1;
      } else if (this.auditform.verityStatus == 1) {
        list.verityStatus = 2;
      }
      this.$confirm("确认审核数据通过？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          auditInfo(list).then((response) => {
            this.msgSuccess("审核通过");
            this.auditopen = false;
            this.getList();
          });
        })
        .catch(() => {});
    },
    // 审核   取消按钮
    auditcancel() {
      this.auditopen = false;
      // 控制  查重里面的查看   不出现审核按钮
      this.chashow = true;
    },
    // 批量审核按钮
    // batchaudit(){
    //   this.auditopen = true
    //   this.audittitle = "批量审核"
    //   let list = {
    //     pageNum: 1,
    //     pageSize: 50,
    //   }
    //   listInfo(this.addDateRange(list)).then(response => {
    //     this.auditform = response.rows
    //   });
    // },

    /** 修改状态提交按钮 */
    threesubmitForm() {
      let num = 0;
      let list = {};
      list.id = this.theform.id;
      list.useStatus = this.theform.useStatus;
      if (list.useStatus == 1) {
        list.lockEndTime = this.theform.lockEndTime;
      }
      if (list.useStatus == 1) {
        if (list.lockEndTime != null) {
          num = 1;
        } else {
          num = 2;
        }
      } else {
        num = 1;
      }
      if (num == 1) {
        this.$confirm("是否确认修改状态？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            questionsInfo(list).then((response) => {
              this.msgSuccess("修改成功");
              this.threeopen = false;
              this.getList();
            });
          })
          .catch(() => {});
      } else {
        this.$confirm("封存状态下，必须选择封存期限！", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).catch(() => {});
      }
    },

    // 隔行效果
    tableRowClassName({ row, rowIndex }) {
      if ((rowIndex + 1) % 2 === 0) {
        return "warning-row";
      } else {
        return "success-row";
      }
    },
    // 序号
    indexMetthod: function (index) {
      return (
        (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
      );
    },
    // 历史序号
    towindexMetthod: function (index) {
      return (this.historyid.pageNum - 1) * this.historyid.pageSize + index + 1;
    },
    // 科目下拉列表   加搜索
    xialaList() {
      this.loading = true;
      listType().then((response) => {
        this.kelist = response.rows;
        this.loading = false;
      });
    },
    // 科目    搜索   联动 章
    infochange() {
      this.outlineList = []; //点击新增的时候清空二级联动  知识点
      this.jlist = []; //点击新增的时候清空二级联动   节
      this.zlist = []; //点击新增的时候清空二级联动  章
      if (this.queryParams.knowledgeId !== null) {
        this.queryParams.knowledgeId = null; //选择科目的时候清空知识点
      }
      if (this.queryParams.zhang !== null) {
        this.queryParams.zhang = null; //点击新增的时候清空二级联动   章
      }
      if (this.queryParams.jie !== null) {
        this.queryParams.jie = null; //点击新增的时候清空二级联动   节
      }
      // if(this.queryParams.questionModuleId !== null){
      //   this.queryParams.questionModuleId = null
      // }
      let list = { ...this.listers };
      list.subjectId = this.queryParams.subjectId;
      list.parentId = 0;
      let type = 0;
      // 章列表查询
      outlineinfo(list, type).then((response) => {
        this.queryParams.knowledge = null;
        this.zlist = response.rows;
        this.loading = false;
      });
    },
    // 科目二级联动  获取知识点下拉列表
    kmtwo() {
      if (this.form.knowledgeId !== null) {
        this.form.knowledgeId = null; //选择科目的时候清空知识点
      }
      if (this.form.zhang !== null) {
        this.form.zhang = null; //点击新增的时候清空二级联动   章
      }
      if (this.form.jie !== null) {
        this.form.jie = null; //点击新增的时候清空二级联动   节
      }
      // if(this.form.questionModuleId !== null){
      //   this.form.questionModuleId = null
      // }
      this.outlineList = []; //点击新增的时候清空二级联动  知识点
      this.zlist = []; //点击新增的时候清空二级联动   章
      this.jlist = []; //点击新增的时候清空二级联动   节

      // 章列表查询
      if (this.open) {
        let list = { ...this.listers };
        list.subjectId = this.form.subjectId;
        list.parentId = 0;
        let type = 0;
        outlineinfo(list, type).then((response) => {
          this.form.knowledge = null;
          this.zlist = response.rows;
          this.loading = false;
        });

        // 科目题型都存在时发科目请求 ****模块下拉列表****
        // if(this.form.subjectId != null){
        //   this.lianlist.questionTypeId = list.questionTypeId
        //   this.lianlist.subjectId = list.subjectId
        //   moduleinfo(this.lianlist,this.lianlist.subjectId,this.lianlist.questionTypeId).then(response => {
        //     this.modulelist = response.rows;
        //   });
        // }
      } else {
      }
    },
    zchange() {
      console.log(this.form.zhang, "章");
      console.log(this.form.questionTypeId, "题型");
      if (this.form.zhang == 45) {
        console.log("章 == 资料分析的时候改变题型");
        this.form.questionTypeId = 5;
        this.questionTypechange(5);
      }
      if (this.open) {
        if (this.form.knowledgeId !== null) {
          this.form.knowledgeId = null; //点击新增的时候清空二级联动  知识点
        }
        if (this.form.jie !== null) {
          this.form.jie = null; //点击新增的时候清空二级联动   节
        }
        this.outlineList = []; //点击新增的时候清空二级联动  知识点
        this.jlist = []; //点击新增的时候清空二级联动   节
        // 章列表查询
        let list = { ...this.listers };
        list.subjectId = this.form.subjectId;
        list.parentId = this.form.zhang;
        let type = this.form.zhang;
        outlineinfo(list, type).then((response) => {
          this.jlist = response.rows;
          this.loading = false;
        });
      } else {
        if (this.queryParams.knowledgeId !== null) {
          this.queryParams.knowledgeId = null; //点击新增的时候清空二级联动  知识点
        }
        if (this.queryParams.jie !== null) {
          this.queryParams.jie = null; //点击新增的时候清空二级联动   节
        }
        this.outlineList = []; //点击新增的时候清空二级联动  知识点
        this.jlist = []; //点击新增的时候清空二级联动   节
        let list = { ...this.listers };
        list.subjectId = this.queryParams.subjectId;
        list.parentId = this.queryParams.zhang;
        let type = this.queryParams.zhang;
        outlineinfo(list, type).then((response) => {
          this.jlist = response.rows;
          this.loading = false;
        });
      }
    },
    jchange() {
      if (this.open) {
        if (this.form.knowledgeId !== null) {
          this.form.knowledgeId = null; //点击新增的时候清空二级联动  知识点
        }
        this.outlineList = []; //点击新增的时候清空二级联动  知识点
        // 节列表查询
        let list = { ...this.listers };
        list.subjectId = this.form.subjectId;
        list.parentId = this.form.jie;
        let type = this.form.jie;
        outlineinfo(list, type).then((response) => {
          this.outlineList = response.rows;
          this.loading = false;
        });
      } else {
        if (this.queryParams.knowledgeId !== null) {
          this.queryParams.knowledgeId = null; //点击新增的时候清空二级联动  知识点
        }
        this.outlineList = []; //点击新增的时候清空二级联动  知识点
        let list = { ...this.listers };
        list.subjectId = this.queryParams.subjectId;
        list.parentId = this.queryParams.jie;
        let type = this.queryParams.jie;
        outlineinfo(list, type).then((response) => {
          this.outlineList = response.rows;
          this.loading = false;
        });
      }
    },
    //知识点change事件
    impidchange(value) {
      // 选择知识点的时候联动知识点重要度
      for (let i = 0; i < this.outlineList.length; i++) {
        if (this.outlineList[i].id == value) {
          this.form.importanceId = this.outlineList[i].importanceId;
        }
      }
    },
    // 科目下拉列表
    typeget() {
      this.loading = true;
      typeinfo().then((response) => {
        this.typelist = response.rows;
        this.loading = false;
      });
    },
    // 命题人下拉
    personget() {
      this.loading = true;
      personinfo().then((response) => {
        this.personlist = response.data;
        this.loading = false;
      });
      console.log(this.personlist, "this.personlist");
    },
    // 难易度下拉列表
    difficultyget() {
      this.loading = true;
      difficultyinfo().then((response) => {
        this.difficultylist = response.rows;
        this.loading = false;
      });
    },
    // 地市下拉列表
    areaget() {
      this.loading = true;
      let pid = 0;
      areainfo(this.fordishi, pid).then((response) => {
        this.arealist = response.rows;
        this.loading = false;
      });
    },
    //选择省时清空市区list并且改变市区list
    changearea(value) {
      let list = { ...this.form };
      list.belongArea = list.shi;
      let type = list.belongArea;
      // 区市列表查询
      areainfo(list, type).then((response) => {
        this.form.belongArea = null; //选择省时清空市区list并且改变市区list
        this.qulist = response.rows;
        this.loading = false;
      });
    },
    //区change事件
    changequ(value) {},
    //题型change事件
    questionTypechange(value) {
      //切换题型的时候清空选项
      if (value == 1 || value == 2) {
        //判断为多选单选的时候
        let list = [
          {
            instatus: false,
            option: "【A】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【B】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【C】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【D】",
            isAnswer: 0,
            remark: null,
          },
        ];
        this.form.rtOptionsInfos = list;
      } else if (value == 4) {
        //判断为判断的时候
        let list = [
          {
            instatus: false,
            isAnswer: 0,
            text: "正确",
          },
          {
            instatus: false,
            isAnswer: 0,
            text: "错误",
          },
        ];
        this.form.rtOptionsInfos = list;
      } else if (value == 5) {
        //判断为案例题的时候
        if (this.form.zhang == 45) {
          let list = [
            {
              close: "×",
              questionTypeId: 1,
              difficulty: 1,
              questionsContent: null,
              answer: null,
              rtOptionsInfos: [
                {
                  instatus: false,
                  option: "【A】",
                  isAnswer: 0,
                  remark: null,
                },
                {
                  instatus: false,
                  option: "【B】",
                  isAnswer: 0,
                  remark: null,
                },
                {
                  instatus: false,
                  option: "【C】",
                  isAnswer: 0,
                  remark: null,
                },
                {
                  instatus: false,
                  option: "【D】",
                  isAnswer: 0,
                  remark: null,
                },
              ],
              index: 1,
            },
          ];
          this.form.rtQuestionsInfos = list;
        } else {
          let list = [
            {
              close: "×",
              questionTypeId: 1,
              questionsContent: null,
              answer: null,
              rtOptionsInfos: [
                {
                  instatus: false,
                  option: "【A】",
                  isAnswer: 0,
                  remark: null,
                },
                {
                  instatus: false,
                  option: "【B】",
                  isAnswer: 0,
                  remark: null,
                },
                {
                  instatus: false,
                  option: "【C】",
                  isAnswer: 0,
                  remark: null,
                },
                {
                  instatus: false,
                  option: "【D】",
                  isAnswer: 0,
                  remark: null,
                },
              ],
              index: 1,
            },
          ];
          this.form.rtQuestionsInfos = list;
        }
        // this.form.rtQuestionsInfos = list
        this.form.rtOptionsInfos = [];
      } else if ((value = 6)) {
        this.form.answer = null;
      } else {
      }
      let list = { ...this.form };
      // 模块下拉列表
      // if(this.form.subjectId != null){
      //   this.lianlist.questionTypeId = list.questionTypeId
      //   this.lianlist.subjectId = list.subjectId
      //   moduleinfo(this.lianlist,this.lianlist.subjectId,this.lianlist.questionTypeId).then(response => {
      //     this.modulelist = response.rows;
      //   });
      // }
    },
    // 案例题型change事件
    antixingchange(index) {
      if (this.form.rtQuestionsInfos[index].questionTypeId == 6) {
        this.form.rtQuestionsInfos[index].rtOptionsInfos = [];
      } else if (this.form.rtQuestionsInfos[index].questionTypeId == 1) {
        let list = [
          {
            instatus: false,
            option: "【A】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【B】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【C】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【D】",
            isAnswer: 0,
            remark: null,
          },
        ];
        this.form.rtQuestionsInfos[index].rtOptionsInfos = list;
      }
    },
    // 案例题固定错误率change事件
    ancwlchange(row) {
      console.log(row, "row");
      let num = null;
      let count = null;
      for (let i = 0; i < row.length; i++) {
        num = row[i].difficulty + num;
        console.log(num, "num");
      }
      count = Math.ceil(num / row.length);
      // console.log(num,'num')
      console.log(count, "count");
      this.form.difficulty = count;
    },
    //选择ABCD选框状态
    xuanchange(index) {
      let form = this.form;
      if (form.questionTypeId == 1) {
        let list = this.form.rtOptionsInfos;
        if (list[index].isAnswer == 1) {
          list[index].instatus = false;
          list[index].isAnswer = 0;
          this.form.rtOptionsInfos = list;
        } else {
          // 遍历出所有选项替换成未选择    根据选中的改变正确答案的状态
          for (let i = 0; i < list.length; i++) {
            list[i].instatus = false;
            list[i].isAnswer = 0;
          }
          // 赋值但前点击的选择框
          list[index].instatus = true;
          list[index].isAnswer = 1;
          //重新获取改完后的数据
          this.form.rtOptionsInfos = this.form.rtOptionsInfos;
        }
      } else if (form.questionTypeId == 2) {
        let list = this.form.rtOptionsInfos;
        if (list[index].instatus == false) {
          list[index].instatus = false;
          list[index].isAnswer = 0;
        } else if (list[index].instatus == true) {
          list[index].instatus = true;
          list[index].isAnswer = 1;
        }
        this.form.rtOptionsInfos = list;
      } else if (form.questionTypeId == 4) {
        let list = this.form.rtOptionsInfos;
        console.log(list, "list");
        console.log(list[index].instatus, "list[index].instatus");
        if (list[index].instatus == true) {
          for (let i = 0; i < list.length; i++) {
            list[i].instatus = false;
            list[i].isAnswer = 0;
          }
          list[index].instatus = true;
          list[index].isAnswer = 1;
          if (list[0].instatus == true) {
            this.form.isCorrect = 1;
          } else if (list[1].instatus == true) {
            this.form.isCorrect = 0;
          }
        } else {
          for (let i = 0; i < list.length; i++) {
            list[i].instatus = false;
            list[i].isAnswer = 0;
          }
        }

        this.form.rtOptionsInfos = list;
        console.log(list, "listgaiwan");
      } else if (form.questionTypeId == 5) {
      }
      this.$forceUpdate(); //重新渲染
    },
    // 点击动态添加单选题
    jiaclick() {
      let index = this.form.rtOptionsInfos.length;
      let singledata = {
        instatus: false,
        option: this.test_Atrr[index],
        isAnswer: 0,
        remark: null,
      };
      if (index < 10) {
        this.form.rtOptionsInfos.push(singledata);
      }
    },
    // 案例题添加小题
    caseclickxiao() {
      let index = this.form.rtQuestionsInfos.length;
      if (this.form.zhang == 45) {
        let list = {
          close: "×",
          questionTypeId: 1,
          difficulty: 1,
          questionsContent: null,
          rtOptionsInfos: [
            {
              instatus: false,
              option: "【A】",
              isAnswer: 0,
              remark: null,
            },
            {
              instatus: false,
              option: "【B】",
              isAnswer: 0,
              remark: null,
            },
            {
              instatus: false,
              option: "【C】",
              isAnswer: 0,
              remark: null,
            },
            {
              instatus: false,
              option: "【D】",
              isAnswer: 0,
              remark: null,
            },
          ],
          index: index + 1,
        };
        this.form.rtQuestionsInfos.push(list);
        let row = this.form.rtQuestionsInfos;
        let num = null;
        let count = null;
        for (let i = 0; i < row.length; i++) {
          num = row[i].difficulty + num;
          console.log(num, "num");
        }
        count = Math.ceil(num / row.length);
        // console.log(num,'num')
        console.log(count, "count");
        this.form.difficulty = count;
      } else {
        let list = {
          close: "×",
          questionTypeId: 1,
          questionsContent: null,
          rtOptionsInfos: [
            {
              instatus: false,
              option: "【A】",
              isAnswer: 0,
              remark: null,
            },
            {
              instatus: false,
              option: "【B】",
              isAnswer: 0,
              remark: null,
            },
            {
              instatus: false,
              option: "【C】",
              isAnswer: 0,
              remark: null,
            },
            {
              instatus: false,
              option: "【D】",
              isAnswer: 0,
              remark: null,
            },
          ],
          index: index + 1,
        };
        this.form.rtQuestionsInfos.push(list);
      }
    },
    // 案例题动态添加 ABCDEFG选项
    caseclick(index) {
      let num = this.form.rtQuestionsInfos[index].rtOptionsInfos.length;
      let list = {
        instatus: false,
        option: this.test_Atrr[num],
        isAnswer: 0,
        remark: null,
      };
      if (num < 10) {
        this.form.rtQuestionsInfos[index].rtOptionsInfos.push(list);
      }
    },
    // 案例的小题单选  选择正确答案
    casechange(key, index) {
      // this.form.rtQuestionsInfos[index].rtOptionsInfos
      // 遍历出所有选项替换成未选择    根据选中的改变正确答案的状态
      let list = [];
      list = this.form.rtQuestionsInfos[index].rtOptionsInfos;
      if (list[key].isAnswer == 1) {
        list[key].instatus = false;
        list[key].isAnswer = 0;
        // this.form.rtQuestionsInfos[index].rtOptionsInfos = list
      } else {
        for (let i = 0; i < list.length; i++) {
          list[i].instatus = false;
          list[i].isAnswer = 0;
        }
        // 赋值但前点击的选择框
        list[key].instatus = true;
        list[key].isAnswer = 1;
        //重新获取改完后的数据
        // this.form.rtQuestionsInfos[index].rtOptionsInfos = list
      }
      this.form.rtQuestionsInfos[index].rtOptionsInfos = list;
      this.$forceUpdate(); //重新渲染
    },
    // 案例题动态添加
    casecjianclick(index) {
      if (this.form.rtQuestionsInfos[index].rtOptionsInfos.length > 1) {
        this.form.rtQuestionsInfos[index].rtOptionsInfos.pop();
      }
    },
    //点击 - 删除选项
    jianclick(index) {
      if (this.form.rtOptionsInfos.length > 1) {
        this.form.rtOptionsInfos.pop();
      }
    },
    // 点击×关闭当前小题
    cancelCase(index) {
      if (this.form.rtQuestionsInfos.length > 1) {
        this.form.rtQuestionsInfos.splice(index, 1);
      }
    },
    /** 查询试题信息列表 */
    getList() {
      this.loading = true;
      listInfo(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          // console.log(response, "response");
          response.rows.forEach((item, index) => {
            let i = item.questionsContent.slice(0, 3);
            if (i === "<p>") {
              // console.log("第" + index + "行");
              item.questionsContent = item.questionsContent.slice(
                3,
                item.questionsContent.length - 4
              );
            }
          });
          this.infoList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      this.outlineList = []; //点击取消的时候清空二级联动  知识点
      this.zlist = []; //点击取消的时候清空二级联动   章
      this.jlist = []; //点击取消的时候清空二级联动   节
    },
    // 取消按钮 历史
    towcancel() {
      this.towopen = false;
    },
    // 取消按钮 修改状态
    threecancel() {
      this.threeopen = false;
    },
    chacel() {
      this.chatopen = false;
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        subjectId: null,
        knowledgeId: null,
        questionsContent: null,
        importanceId: null,
        questionTypeId: 1,
        questionModuleId: null,
        difficulty: null,
        expertName: null,
        createTime: null,
        status: null,
        aging: 1,
        belongArea: null,
        rtOptionsInfos: [
          {
            instatus: false,
            option: "【A】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【B】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【C】",
            isAnswer: 0,
            remark: null,
          },
          {
            instatus: false,
            option: "【D】",
            isAnswer: 0,
            remark: null,
          },
        ],
        rtQuestionsInfos: [],
        answer: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.zlist = [];
      this.jlist = [];
      this.outlineList = [];
      this.queryParams.examTypeId = null;
      this.queryParams.questionTypeId = null;
      this.resetForm("queryForm");
      this.handleQuery();
    },
    getUser() {
      getUserProfile().then((response) => {
        this.user = response.data;
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.geiyas = false;
      this.modulelist = []; //点击新增的时候清空二级联动   模块
      this.outlineList = []; //点击新增的时候清空二级联动  知识点
      this.zlist = []; //点击新增的时候清空二级联动   章
      this.jlist = []; //点击新增的时候清空二级联动   节
      this.reset();
      this.open = true;
      this.title = "添加试题";
      this.$nextTick(() => {
        this.$refs.gain.focus();
      });
      //难易度下拉
      this.difficultyget();
      // 命题人下拉
      this.personget();
      //地市下拉
      this.areaget();
      this.form.difficulty = 1;
      // this.form.expertName = this.user.nickName
    },
    // 启用按钮
    handlestart(row) {
      let statuslist = this.statuslist;
      statuslist.id = row.id;
      statuslist.status = row.status;
      if (statuslist.status == 0) {
        statuslist.status = 1;
      }
      forbidden(statuslist).then((response) => {
        this.getList();
      });
    },
    //禁用按钮
    handleforbidden(row) {
      let statuslist = this.statuslist;
      statuslist.id = row.id;
      statuslist.status = row.status;
      if (statuslist.status == 1) {
        statuslist.status = 0;
      }
      forbidden(statuslist).then((response) => {
        this.getList();
      });
    },
    /** 修改反显按钮操作  */
    handleUpdate(row) {
      this.geiyas = true;
      const id = row.id || this.ids;
      getInfo(id).then((response) => {
        // 获取修改返回值
        this.form = response.data;
        // 获取科目id查询知识点下拉列表
        this.xiuformlist.subjectId = this.form.subjectId;
        // 赋值科目id传给后台
        let type = this.xiuformlist.subjectId;
        // 根据科目id查询知识点列表
        outlineinfo(this.xiuformlist, type).then((response) => {
          this.outlineList = response.rows;
          // 根据知识点查询节
          for (let i = 0; i < this.outlineList.length; i++) {
            if (this.outlineList[i].id == this.form.knowledgeId) {
              let jid = this.outlineList[i].parentId;
              for (let j = 0; j < this.outlineList.length; j++) {
                if (this.outlineList[j].id == jid) {
                  let zhangid = this.outlineList[j].parentId;

                  // let xlisters = {...this.xlisters}
                  // xlisters.subjectId = this.form.subjectId
                  // xlisters.parentId = this.outlineList[j].parentId
                  // let type = this.outlineList[j].parentId
                  // console.log(zhangid,'zhangid')
                  // console.log(this.xlisters,'this.xlistersthis.xlisters')
                  // outlineinfo(this.xlisters,type).then(response => {
                  //   this.jlist = response.rows;
                  //   console.log(this.jlist,'jlist')
                  // });
                  this.form.jie = Number(jid);
                  // xlisters.parentId = this.outlineList[j].parentId
                  // let typeid = this.form.subjectId
                  // outlineinfo(this.xlisters,typeid,).then(response => {
                  //   this.zlist = response.rows;
                  // });
                  this.form.zhang = Number(zhangid);

                  let list = { ...this.listers };
                  list.subjectId = this.form.subjectId;
                  list.parentId = 0;
                  let zhangtype = this.form.zhang;
                  outlineinfo(list, zhangtype).then((response) => {
                    this.zlist = response.rows;
                  });
                  list.parentId = this.form.zhang;
                  outlineinfo(list, this.form.zhang).then((response) => {
                    this.jlist = response.rows;
                  });
                  list.parentId = this.form.jie;
                  outlineinfo(list, this.form.jie).then((response) => {
                    this.outlineList = response.rows;
                  });
                }
              }
            }
          }
        });

        // 反显需要转Number
        this.form.knowledgeId = Number(this.form.knowledgeId);
        // 请求模块列表 反显
        // if(this.form.subjectId!=null && this.form.questionTypeId!=null){
        //   this.lianlist.questionTypeId = this.form.questionTypeId
        //   this.lianlist.subjectId = this.form.subjectId
        //   moduleinfo(this.lianlist,this.lianlist.subjectId,this.lianlist.questionTypeId).then(response => {
        //     this.modulelist = response.rows;
        //   });
        // }

        // moduleinfo().then(response => {
        //   this.modulelist = response.rows;
        // });
        // 请求错误率列表反显  错误率没有联动直接请求
        this.difficultyget();
        // 请求命题人列表反显  命题人没有联动直接请求
        this.personget();
        this.form.expertName = Number(this.form.expertName);
        // 判断有没有选择地市
        if (this.form.belongArea != null) {
          // 反显地市 获取地市省级下拉
          areainfo(this.fordishi, 0).then((response) => {
            this.arealist = response.rows;
            this.loading = false;
          });
          // 存市的id
          let id = this.form.belongArea;
          // 存省的id
          let pid = null;
          //请求全部的省和市
          areasinfo()
            .then((response) => {
              let list = [];
              list = response.rows;
              // 遍历id跟返回值一样的id
              for (let i = 0; i < list.length; i++) {
                if (list[i].id == id) {
                  pid = list[i].pid;
                  this.form.shi = pid;
                }
              }
            })
            .then(() => {
              areainfo(this.form, pid).then((response) => {
                this.qulist = response.rows;
              });
            });
        } else {
          areainfo(this.fordishi, 0).then((response) => {
            this.arealist = response.rows;
            this.loading = false;
          });
        }

        // 判断题型 单选题
        if (this.form.questionTypeId == 1) {
          let rtlist = this.form.rtOptionsInfos;
          for (let i = 0; i < this.form.rtOptionsInfos.length; i++) {
            if (rtlist[i].isAnswer == 1) {
              rtlist[i].instatus = true;
            } else if (rtlist[i].isAnswer == 0) {
              rtlist[i].instatus = false;
            } else {
            }
            rtlist[i].option = this.test_Atrr[i];
          }
        } else if (this.form.questionTypeId == 2) {
          //多选题
          let rtlist = this.form.rtOptionsInfos;
          for (let i = 0; i < this.form.rtOptionsInfos.length; i++) {
            if (rtlist[i].isAnswer == 1) {
              rtlist[i].instatus = true;
            } else if (rtlist[i].isAnswer == 0) {
              rtlist[i].instatus = false;
            } else {
            }
            rtlist[i].option = this.test_Atrr[i];
          }
        } else if (this.form.questionTypeId == 4) {
          //判断题
          if (this.form.isCorrect == 0) {
            let list = [
              {
                instatus: false,
                isAnswer: 0,
                text: "正确",
              },
              {
                instatus: true,
                isAnswer: 1,
                text: "错误",
              },
            ];
            this.form.rtOptionsInfos = list;
          } else if (this.form.isCorrect == 1) {
            let list = [
              {
                instatus: true,
                isAnswer: 1,
                text: "正确",
              },
              {
                instatus: false,
                isAnswer: 0,
                text: "错误",
              },
            ];
            this.form.rtOptionsInfos = list;
          } else {
            let list = [
              {
                instatus: false,
                isAnswer: 0,
                text: "正确",
              },
              {
                instatus: false,
                isAnswer: 0,
                text: "错误",
              },
            ];
            this.form.rtOptionsInfos = list;
          }
        } else if (this.form.questionTypeId == 5) {
          //案例题
          let rtQinfo = this.form.rtQuestionsInfos;
          for (let i = 0; i < rtQinfo.length; i++) {
            // 判断为单选题的时候进行遍历赋值ABCD等选项
            rtQinfo[i].close = "×";
            if (rtQinfo[i].questionTypeId == 1) {
              for (let j = 0; j < rtQinfo[i].rtOptionsInfos.length; j++) {
                rtQinfo[i].rtOptionsInfos[j].option = this.test_Atrr[j];
                if (rtQinfo[i].rtOptionsInfos[j].isAnswer == 1) {
                  rtQinfo[i].rtOptionsInfos[j].instatus = true;
                } else if (rtQinfo[i].rtOptionsInfos[j].isAnswer == 0) {
                  rtQinfo[i].rtOptionsInfos[j].instatus = false;
                } else {
                }
              }
            }
          }
        }

        this.open = true;
        this.title = "修改试题";
      });
    },
    textti(listres){
      console.log(listres)
      if(listres){
        listres = listres.replace(/<u(.*?)\/u>/g, '____')
        listres = listres.replaceAll("&nbsp;"," ");
      }
    },
    /** 提交按钮 */
    submitForm() {
      console.log(this.form, "提交");
      // console.log(this.form.questionsContent,'questionsContent')
      // console.log(this.form.rtQuestionsInfos,'rtQuestionsInfos')
      // 判断是什么题型
      if (this.form.questionsContent == "<p><br></p>") {
        this.form.questionsContent = null;
      }
      let rum = null;
      if (this.form.questionTypeId == 1) {
        // 单选题
        if (this.form.rtOptionsInfos.length > 3) {
          for (let i = 0; i < this.form.rtOptionsInfos.length; i++) {
            if (this.form.rtOptionsInfos[i].remark == "<p><br></p>") {
              this.form.rtOptionsInfos[i].remark = null;
            }
            if (this.form.rtOptionsInfos[i].instatus !== false) {
              rum = 0;
              i = this.form.rtOptionsInfos.length;
            } else {
              rum = 1;
            }
          }
        } else {
          rum = 2;
        }
      } else if (this.form.questionTypeId == 2) {
        // 多选题
        if (this.form.rtOptionsInfos.length > 3) {
          for (let i = 0; i < this.form.rtOptionsInfos.length; i++) {
            if (this.form.rtOptionsInfos[i].remark == "<p><br></p>") {
              this.form.rtOptionsInfos[i].remark = null;
            }
            if (this.form.rtOptionsInfos[i].instatus !== false) {
              rum = 0;
              i = this.form.rtOptionsInfos.length;
            } else {
              rum = 4;
            }
          }
        } else {
          rum = 3;
        }
      } else if (this.form.questionTypeId == 3) {
        // 填空题
        rum = 404;
      } else if (this.form.questionTypeId == 4) {
        // 判断题
        if (
          this.form.rtOptionsInfos[0].instatus == false &&
          this.form.rtOptionsInfos[1].instatus == false
        ) {
          rum = 5;
        } else {
          rum = 0;
        }
      } else if (this.form.questionTypeId == 5) {
        // 案例题
        let rtQinfo = this.form.rtQuestionsInfos;
        for (let i = 0; i < rtQinfo.length; i++) {
          if (rtQinfo[i].questionTypeId == 1) {
            if (rtQinfo.length > 1) {
              if (rtQinfo[0].questionTypeId == 6) {
                if (rum == 0) {
                  if (
                    rtQinfo[i].questionsContent == null ||
                    rtQinfo[i].questionsContent == "<p><br></p>"
                  ) {
                    rum = 6;
                  } else {
                    if (rtQinfo[i].rtOptionsInfos.length > 3) {
                      for (
                        let j = 0;
                        j < rtQinfo[i].rtOptionsInfos.length;
                        j++
                      ) {
                        if (
                          rtQinfo[i].rtOptionsInfos[j].remark != null &&
                          rtQinfo[i].rtOptionsInfos[j].remark != "<p><br></p>"
                        ) {
                          if (rtQinfo[i].rtOptionsInfos[j].instatus !== false) {
                            rum = 0;
                          } else {
                            if (rum != 0) {
                              rum = 8;
                            }
                          }
                        } else {
                          rum = 666;
                          j = rtQinfo[i].rtOptionsInfos.length;
                        }
                      }
                    } else {
                      rum = 7;
                      i = rtQinfo.length;
                    }
                  }
                }
              } else {
                if (
                  rtQinfo[i].questionsContent == null ||
                  rtQinfo[i].questionsContent == "<p><br></p>"
                ) {
                  rum = 6;
                } else {
                  if (rtQinfo[i].rtOptionsInfos.length > 3) {
                    for (let j = 0; j < rtQinfo[i].rtOptionsInfos.length; j++) {
                      if (
                        rtQinfo[i].rtOptionsInfos[j].remark != null &&
                        rtQinfo[i].rtOptionsInfos[j].remark != "<p><br></p>"
                      ) {
                        if (rtQinfo[i].rtOptionsInfos[j].instatus !== false) {
                          rum = 0;
                        } else {
                          if (rum != 0) {
                            rum = 8;
                          }
                        }
                      } else {
                        rum = 666;
                        j = rtQinfo[i].rtOptionsInfos.length;
                      }
                    }
                  } else {
                    rum = 7;
                    i = rtQinfo.length;
                  }
                }
              }
            } else {
              if (
                rtQinfo[i].questionsContent == null ||
                rtQinfo[i].questionsContent == "<p><br></p>"
              ) {
                rum = 6;
              } else {
                if (rtQinfo[i].rtOptionsInfos.length > 3) {
                  for (let j = 0; j < rtQinfo[i].rtOptionsInfos.length; j++) {
                    if (
                      rtQinfo[i].rtOptionsInfos[j].remark != null &&
                      rtQinfo[i].rtOptionsInfos[j].remark != "<p><br></p>"
                    ) {
                      if (rtQinfo[i].rtOptionsInfos[j].instatus !== false) {
                        rum = 0;
                      } else {
                        if (rum != 0) {
                          rum = 8;
                        }
                      }
                    } else {
                      rum = 666;
                      j = rtQinfo[i].rtOptionsInfos.length;
                    }
                  }
                } else {
                  rum = 7;
                  i = rtQinfo.length;
                }
              }
            }
          } else if (
            rtQinfo[i].questionTypeId == 6 ||
            rtQinfo[i].questionsContent == "<p><br></p>"
          ) {
            if (rtQinfo.length > 1) {
              if (rtQinfo[0].questionTypeId == 1) {
                if (rum == 0) {
                  if (
                    rtQinfo[i].questionsContent != null &&
                    rtQinfo[i].questionsContent != "<p><br></p>"
                  ) {
                    if (
                      rtQinfo[i].answer != null &&
                      rtQinfo[i].answer != "<p><br></p>"
                    ) {
                      rum = 0;
                    } else {
                      rum = 10;
                    }
                  } else {
                    rum = 9;
                  }
                }
              } else {
                if (
                  rtQinfo[i].questionsContent != null &&
                  rtQinfo[i].questionsContent != "<p><br></p>"
                ) {
                  if (
                    rtQinfo[i].answer != null &&
                    rtQinfo[i].answer != "<p><br></p>"
                  ) {
                    rum = 0;
                  } else {
                    rum = 10;
                  }
                } else {
                  rum = 9;
                }
              }
            } else {
              if (
                rtQinfo[i].questionsContent != null &&
                rtQinfo[i].questionsContent != "<p><br></p>"
              ) {
                if (
                  rtQinfo[i].answer != null &&
                  rtQinfo[i].answer != "<p><br></p>"
                ) {
                  rum = 0;
                } else {
                  rum = 10;
                }
              } else {
                rum = 9;
              }
            }
          }
        }
      } else if (this.form.questionTypeId == 6) {
        // 问答题
        if (
          this.form.answer != null &&
          this.form.answer != "<p><br></p>" &&
          this.form.questionsContent != null &&
          this.form.questionsContent != "<p><br></p>"
        ) {
          rum = 0;
        } else {
          if (this.form.answer == "<p><br></p>") {
            rum = 11;
          }
        }
      }
      if(rum == 0){
        if(this.form.specificBackground){
          this.form.specificBackground = this.form.specificBackground.replace(/<u(.*?)\/u>/g, '____')
          this.form.specificBackground = this.form.specificBackground.replace(/&nbsp;/g," ");
        }
        if(this.form.questionsContent){
          this.form.questionsContent = this.form.questionsContent.replace(/<u(.*?)\/u>/g, '____')
          this.form.questionsContent = this.form.questionsContent.replace(/&nbsp;/g," ");
        }
        // this.textti(this.form.specificBackground)
        // this.textti(this.form.questionsContent)
        if(this.form.questionTypeId == 1 || this.form.questionTypeId == 2){
          // 选择多选
          for(let i = 0;i<this.form.rtOptionsInfos.length;i++){
              this.form.rtOptionsInfos[i].remark = this.form.rtOptionsInfos[i].remark.replace(/<u(.*?)\/u>/g, '____')
              this.form.rtOptionsInfos[i].remark = this.form.rtOptionsInfos[i].remark.replace(/&nbsp;/g," ");
          }
        }else if(this.form.questionTypeId == 5){
          // 案例
          let rtQinfo = this.form.rtQuestionsInfos;
          if(rtQinfo.questionTypeId == 1){
            for(let i = 0;i<rtQinfo.length;i++){
              // this.textti(rtQinfo[i].questionsContent)
              if(rtQinfo[i].questionsContent){
                rtQinfo[i].questionsContent = rtQinfo[i].questionsContent.replace(/<u(.*?)\/u>/g, '____')
                rtQinfo[i].questionsContent = rtQinfo[i].questionsContent.replace(/&nbsp;/g," ");
              }
              for(let j = 0;j <rtQinfo[i].rtOptionsInfos.length;j ++){
                // this.textti(rtQinfo[i].rtOptionsInfos[j].remark)
                if(rtQinfo[i].rtOptionsInfos[j].remark){
                  rtQinfo[i].rtOptionsInfos[j].remark = rtQinfo[i].rtOptionsInfos[j].remark.replace(/<u(.*?)\/u>/g, '____')
                  rtQinfo[i].rtOptionsInfos[j].remark = rtQinfo[i].rtOptionsInfos[j].remark.replace(/&nbsp;/g," ");
                }
              }
            }
          }else{
            for(let i = 0;i<rtQinfo.length;i++){
              if(rtQinfo[i].answer){
                rtQinfo[i].answer = rtQinfo[i].answer.replace(/<u(.*?)\/u>/g, '____')
                rtQinfo[i].answer = rtQinfo[i].answer.replace(/&nbsp;/g," ");
              }
            }
          }
          
        }else if(this.form.questionTypeId == 6){
          // 问答
          if(this.form.answer){
            this.form.answer = this.form.answer.replace(/<u(.*?)\/u>/g, '____')
            this.form.answer = this.form.answer.replace(/&nbsp;/g," ");
          }
          // this.textti(this.form.answer)
        }
      }

      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            if (rum == 0) {
              this.$confirm("是否确认修改数据？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              })
                .then(() => {
                  updateInfo(this.form).then((response) => {
                    this.msgSuccess("修改成功");
                    this.open = false;
                    this.getList();
                  });
                })
                .catch(() => {});
            } else if (rum == 1) {
              this.$confirm("单选题必须选择一项正确答案！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 2) {
              this.$confirm("单选题最少添加四个选项！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 3) {
              this.$confirm("多选题选题最少添加四个选项！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 4) {
              this.$confirm("多选题必须选择一项正确答案！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 5) {
              this.$confirm("判断题必须选择一项正确答案！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 6) {
              this.$confirm("案例题小题中单选题，试题题干不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 7) {
              this.$confirm("案例题小题中单选题，最少添加四个选项！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 8) {
              this.$confirm(
                "案例题小题中单选题，必须选择一项正确答案！",
                "提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              ).catch(() => {});
            } else if (rum == 9) {
              this.$confirm("案例题小题中问答题，试题题干不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 10) {
              this.$confirm("案例题小题中问答题，试题答案不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 666) {
              this.$confirm("案例题选择题中选项内容，不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 11) {
              this.$confirm("问答题答案不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            }
          } else {
            if (rum == 0) {
              this.$confirm("是否确认新增数据？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              })
                .then(() => {
                  addInfo(this.form).then((response) => {
                    this.msgSuccess("新增成功");
                    this.open = false;
                    if (this.open == false) {
                      this.outlineList = []; //点击确定的时候清空二级联动
                    }
                    this.getList();
                  });
                })
                .catch(() => {});
            } else if (rum == 1) {
              this.$confirm("单选题必须选择一项正确答案！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 2) {
              this.$confirm("单选题最少添加四个选项！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 3) {
              this.$confirm("多选题选题最少添加四个选项！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 4) {
              this.$confirm("多选题必须选择一项正确答案！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 5) {
              this.$confirm("判断题必须选择一项正确答案！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 6) {
              this.$confirm("案例题小题中单选题，试题题干不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 7) {
              this.$confirm("案例题小题中单选题，最少添加四个选项！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 8) {
              this.$confirm(
                "案例题小题中单选题，必须选择一项正确答案！",
                "提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              ).catch(() => {});
            } else if (rum == 9) {
              this.$confirm("案例题小题中问答题，试题题干不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 10) {
              this.$confirm("案例题小题中问答题，试题答案不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 666) {
              this.$confirm("案例题选择题中选项内容，不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            } else if (rum == 11) {
              this.$confirm("问答题答案不能为空！", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).catch(() => {});
            }
          }
        }
      });
      if (this.open == false) {
        this.outlineList = []; //点击取消的时候清空二级联动  知识点
        this.zlist = []; //点击取消的时候清空二级联动   章
        this.jlist = []; //点击取消的时候清空二级联动   节
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm("是否确认删除此条数据项！", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delInfo(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "试题导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      // importTemplate().then(response => {
      //   this.download(response.msg);
      // });
      importTemplate().then((response) => {
        const content = response; //后台返回二进制数据
        const blob = new Blob([content]);
        const fileName = "试题维护模板.doc";
        if ("download" in document.createElement("a")) {
          // 非IE下载
          const elink = document.createElement("a"); //创建a标签
          elink.download = fileName; //设置表名
          elink.style.display = "none";
          elink.href = URL.createObjectURL(blob);
          document.body.appendChild(elink);
          elink.click();
          URL.revokeObjectURL(elink.href); // 释放URL 对象
          document.body.removeChild(elink);
        } else {
          // IE10+下载
          navigator.msSaveBlob(blob, fileName);
        }
      });
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert('导入成功', "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
  },
};
</script>
<style scoped>
/* 查重里的查看按钮 */
.chainfoclick {
  color: #1890ff;
  cursor: pointer;
}
/* 截图工具 */
.iconclick {
  position: relative;
  top: 40px;
  left: 150px;
  cursor: pointer;
}
.iconclicks {
  position: relative;
  top: 40px;
  left: 180px;
  cursor: pointer;
}
.red {
  color: #f00;
}
/*  */
.questiontext {
  height: 250px;
}
.noyes {
  display: flex;
  align-items: center;
  margin-right: 40px;
}
.noyes > span {
  margin-left: 20px;
  font-size: 18px;
}
.noyes > input {
  font-size: 20px;
  width: 20px;
  height: 20px;
}
.jian {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}
.jian > span {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  border: 1px solid #999;
  text-align: center;
  font-size: 24px;
  /* margin-top: 100px; */
  position: relative;
  top: -50px;
  cursor: pointer;
}
.jia {
  width: 100px;
  height: 30px;
  line-height: 30px;
  border: 1px solid #999;
  background: #fff;
  font-size: 18px;
  text-align: center;
  margin: auto;
  cursor: pointer;
}
.xuanze {
  margin-right: 40px;
}
.xuanze > span {
  font-size: 18px;
}
.xuanze > input {
  width: 15px;
  height: 15px;
}
/* 案例 */
.casestyle {
  background: rgba(173, 226, 250, 0.2);
  padding: 15px 20px;
  padding-right: 20px;
  margin: 30px 0;
}
.casesjian {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}
.casesjian > span {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  border: 1px solid #999;
  text-align: center;
  font-size: 24px;
  position: relative;
  top: -50px;
  cursor: pointer;
}
.canceldiv > div {
  display: flex;
  justify-content: flex-end;
}
.canceldiv > div > span {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  font-size: 30px;
  cursor: pointer;
}
.canceldiv > p {
  text-align: center;
}
.canceldiv {
  padding-bottom: 20px;
  
}

</style>
<style lang="scss" scoped>
.imgwidth {
  ::v-deep {
    img {
      max-width: 100%;
    }
  }
}
.imgwidth{
  max-width: 900px;
}
</style>
